﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;

public partial class Sys_adviewdialog : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            selectbind();
        }
    }
    //下拉框控件数据绑定
    protected void selectbind()
    {
        if (Request.QueryString["cname"] != null && Request.QueryString["cid"]!=null)
        {
            string cname = Request.QueryString["cname"].ToString().Trim();
            this.HiddenField1.Value = Request.QueryString["cid"].ToString().Trim();
            lblCname.Text = cname;
            PM.PMSys.setmanager setmanager = new PM.PMSys.setmanager();
            int sum = setmanager.GetCount(cname, this.ddlCollege);
            lblsum.Text = " " + sum.ToString();//查询到的记录数即为已注册的教师总数
        } 
        else
        {
            this.ddlCollege.Enabled = false;
        }
    }

    //执行数据库操作,该按钮单击事件有待修改(应同时触发更新Sys_Account和Dict_College两张表)
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (this.ddlCollege.SelectedValue.Trim()=="0")
        {
            btnSubmit.Enabled = false;
            lbltips.Text = "未选择任何教师，操作无效。";
        } 
        else
        {
            PM.PMSys.setmanager setmanager = new PM.PMSys.setmanager();
            int count = setmanager.Appointment(Int32.Parse(this.HiddenField1.Value), this.ddlCollege.SelectedValue.Trim(), this.ddlCollege.SelectedItem.Text.Trim(), "c");
            if (count > 1)
                lbltips.Text = "学院管理员设置成功!";
            else
                lbltips.Text = "设置失败！";
            this.ddlCollege.Enabled = false;
            btnSubmit.Enabled = false;
        }
    }
}
